package com.zhangchuchu.neohealth.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhangchuchu.neohealth.entity.UserProfile;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserProfileMapper extends BaseMapper<UserProfile> {
    // 根据 nickname 查询用户信息
    @Select("SELECT * FROM user_profile WHERE nickname = #{nickname}")
    UserProfile findByNickname(String nickname);
    //根据userId 查询积分
    @Select("SELECT integral FROM user_profile WHERE user_id = #{userId}")
    Integer getIntegralByUserId(@Param("userId") Integer userId);
    //更新积分
    @Update("UPDATE user_profile SET integral = #{newIntegral} WHERE user_id = #{userId}")
    Integer updateIntegralByUserId(@Param("userId") Integer userId, @Param("newIntegral") Integer newIntegral);

}
